import React from 'react'
import useURLLoader from "../hooks/useURLLoader";

const DogShowWithHook = () => {
    const style = {
        width: 200
    };
    const [ data, loading ] = useURLLoader('https://dog.ceo/api/breeds/image/random');

    return (
        <>
            <div>
                {
                    loading
                        ? <p>狗狗读取中</p>
                        : <img src={data && (data.code === '-1' ? data.url : data.message)} alt='dog' style={style}/>

                }
            </div>
        </>
    )
};

export default DogShowWithHook;
